package cn.zust.itcost.service.impl;

import cn.zust.itcost.service.PdfService;
import cn.zust.itcost.utils.PdfUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@Service
public class PdfServiceImpl implements PdfService {

    @Override
    public Map<String, Object> parsePdf(MultipartFile file) throws IOException {
        Map<String, Object> result = new HashMap<>();

        // 获取基本信息
        result.put("basicInfo", PdfUtils.getBasicInfo(file));

        // 获取元数据
        result.put("metadata", PdfUtils.getMetadata(file));

        // 提取文本内容
        result.put("content", PdfUtils.extractText(file));
        System.out.println(111);
        return result;
    }

    @Override
    public String extractText(MultipartFile file) throws IOException {
        return PdfUtils.extractText(file);
    }

    @Override
    public Map<String, String> getMetadata(MultipartFile file) throws IOException {
        return PdfUtils.getMetadata(file);
    }
}
